package com.funong.matrix.core.manager.factory;

import com.funong.matrix.biz.base.entity.SysLogEntity;
import com.funong.matrix.biz.system.domain.SysLogDomainDao;
import com.funong.matrix.core.utils.ip.AddressUtils;
import com.funong.matrix.core.utils.ip.IpUtils;
import com.funong.matrix.core.utils.spring.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.TimerTask;

/**
 * 异步工厂（产生任务用）
 *
 * @author ruoyi
 */
public class AsyncFactory {
    private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");


    /**
     * 操作日志记录
     *
     * @param operLog 操作日志信息
     * @return 任务task
     */
    public static TimerTask recordOper(final SysLogEntity operLog) {
        return new TimerTask() {
            @Override
            public void run() {
                // 远程查询操作地点
//                operLog.setRequestParam(operLog.getRequestParam()+AddressUtils.getRealAddressByIP(IpUtils.getIpAddr()));
                SpringUtils.getBean(SysLogDomainDao.class).saveSystemLogInfo(operLog);
            }
        };
    }
}
